﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Orchard.Data.Migration;

namespace Bootstrap
{
    public class Migrations : DataMigrationImpl
    {
        public int Create() {
            SchemaBuilder.CreateTable(
                "BootstrapFeatureRecord",
                builder =>
                builder
                    .Column<int>("Id", c => c.PrimaryKey().Identity())
                    .Column<string>("Name")
                    .Column<bool>("Enabled")

                );
            SchemaBuilder.CreateTable(
                "BootstrapVariableRecord",
                builder =>
                builder
                    .Column<int>("Id", c => c.PrimaryKey().Identity())
                    .Column<string>("Name")
                    .Column<string>("Value")
                    
                );
            SchemaBuilder
                .CreateTable(
                    "BootstrapSettingRecord",
                    builder =>
                    builder
                        .Column<int>("Id", c => c.PrimaryKey().Identity())
                        .Column<string>("Name")
                        .Column<string>("Value")
                );
            
            return 3;
        }

        public int UpdateFrom1() {
            
            SchemaBuilder.AlterTable("BootstrapFeatureRecord", builder => builder.DropColumn("LastChanged"));
            SchemaBuilder.AlterTable("BootstrapVariableRecord", builder => builder.DropColumn("LastChanged"));

            return 2;
        }

        public int UpdateFrom2() {
            SchemaBuilder
                .CreateTable(
                    "BootstrapSettingRecord",
                    builder =>
                    builder
                        .Column<int>("Id", c => c.PrimaryKey().Identity())
                        .Column<string>("Name")
                        .Column<string>("Value")
                );

            return 3;
        }
    }
}
